import axios from './$http'


const cache = new Map();

const api = {
    clearCache() {
        cache.clear();
    },
    async stepPause(data) {
        const result = await axios.post(`/square-lake/process/test/step_pause`, data);
        return result;
    },
    async stepResume(data) {
        const result = await axios.post(`/square-lake/process/test/step_resume`, data);
        return result;
    },
    async transResumeAll(data) {
        const result = await axios.post(`/square-lake/process/test/trans_resume`, data);
        return result;
    },
    async resumeAll(data) {
        const result = await axios.post(`/square-lake/process/test/trans_resume_all`, data);
        return result;
    },
    async queryJobConfigList() {
        const result = await axios.post(`/square-lake/job/list`, {});
        return result;
    },
    async jobConfigAdd(data) {
        const result = await axios.post(`/square-lake/job/add`, data);
        return result;
    },
    async getJobConfigById(id) {
        const result = await axios.post(`/square-lake/job/get_by_id`, {id});
        return result;
    },
    async updateJobConfigById(data) {
        const result = await axios.post(`/square-lake/job/update_by_id`, data);
        return result;
    },

    async removeById(id) {
        const result = await axios.post(`/square-lake/job/remove/${id}`, {});
        return result;
    },
    async runOneById(id) {
        const result = await axios.post(`/square-lake/job/run_one/${id}`, {});
        return result;
    },
    async run(id) {
        const result = await axios.post(`/square-lake/job/run/${id}`, {});
        return result;
    },
    async stop(id) {
        const result = await axios.post(`/square-lake/job/pause/${id}`, {});
        return result;
    },
    async nextFireTime(id) {
        const result = await axios.post(`/square-lake/job/next_fire_time/${id}`, {});
        return result;
    },
    async queryProcessList() {
        const data = await axios.post("/square-lake/process/list", {groupId: null})
        return data;
    },
    async queryProcessVersionRelationList(processId, bizType) {
        const data = await axios.post("/square-lake/process/relation/version/list", {processId, bizType})
        return data;
    },
    async queryProcessVersionRelationListByBizIdAndType(bizId, bizType) {
        const data = await axios.post("/square-lake/process/relation/list", {bizId, bizType})
        return data;
    },
    async saveProcessRelationConfig(data) {
        const result = await axios.post("/square-lake/process/relation/save", data)
        return result;
    },
    async removeRelation(id) {
        const result = await axios.post(`/square-lake/process/relation/remove/${id}`, {})
        return result;

    },
    async saveApiConfig(data) {
        const result = await axios.post(`/square-lake/api/config/add`, data)
        return result;
    },
    async apiList() {
        const result = await axios.post(`/square-lake/api/config/list`, {})
        return result;

    },
    async queryFieldTypeList() {
        const result = await axios.post(`/square-lake/process/field_type_list`, {})
        return result;
    },
    async updateApiById(data) {
        const result = await axios.post(`/square-lake/api/config/update_by_id`, data)
        return result;
    },
    async queryApiById(id) {
        const result = await axios.post(`/square-lake/api/config/query_by_id`, {id})
        return result;
    },
    async queryApiVersionList(id) {
        const result = await axios.post(`/square-lake/api/config/version/query_by_api_id`, {id})
        return result;
    },
    async queryDefaultResponseWrapper() {
        const result = await axios.post(`/square-lake/api/config/get_default_response_wrapper`, {})
        return result;
    },
    async updateApiStatusCode(id, apiStatusCode) {
        const result = await axios.post(`/square-lake/api/config/set_api_status_code`, {
            id,
            apiStatusCode
        })
        return result;
    },
    async updateApiVersionLatestFlag(id, latestFlag) {
        const result = await axios.post(`/square-lake/api/config/version/set_latest_flag`, {
            id,
            latestFlag
        })
        return result;
    },
    async queryThreadPoolList(data) {
        const result = await axios.post("/square-lake/process/thread/config/list", data)
        return result;
    },
    async post(url,data) {
        const result = await axios.post(url, data)
        return result;
    },
    async get(url,data) {
        const result = await axios.get(url, data)
        return result;
    }
}

export default api;